package pw.goyd.game.handler.imp;

import pw.goyd.db.RedisUtil;
import pw.goyd.game.handler.Handler;
import pw.goyd.game.logic.CompleteResponse;
import pw.goyd.game.server.Log;
import pw.goyd.game.server.LoginList;
import pw.goyd.protocol.model.Response;
import pw.goyd.subscribe.PlayerCustomer;

public class COMPLETE extends Handler {
    /**
     * 完成选牌
     */
    @Override
    public void handle() {
        // 完成
        Response response = new Response();
        PlayerCustomer comPlayer = LoginList.getPlayer(ctx.getChannel().getId());

        CompleteResponse completeResponse = new CompleteResponse();
        completeResponse.setPlayer(comPlayer);
        response.setData(completeResponse.getBytes());
        response.setCmd(CMD_COMPLETE);
        response.setTime(0);
        if (comPlayer != null) {
            RedisUtil.pubRoom(comPlayer.getRoomID(), response.getAllBytes());
        } else {
            Log.getLogger().error("空指针--->ChannelID[" + ctx.getChannel().getId() + "]");
        }

    }

}
